UNAME := $(shell uname)
ifeq ($(UNAME), Darwin)
	LIB_ANGR_NATIVE=angr_native.dylib
endif
ifeq ($(UNAME), Linux)
	LIB_ANGR_NATIVE=angr_native.so
endif

CC := gcc
C++C := g++
CFLAGS := -I ${UNICORN_INCLUDE_PATH} -I ${PYVEX_INCLUDE_PATH} \
	-L ${UNICORN_LIB_PATH} -L ${PYVEX_LIB_PATH} \
	`pkg-config --cflags glib-2.0` -O3 -fPIC -std=c++11

OBJS := log.o
LIBS := `pkg-config --libs glib-2.0` -lunicorn -lpyvex

all: ${LIB_ANGR_NATIVE}

log.o: log.c log.h
	${CC} -fPIC -c -O3 -o $@ $<

${LIB_ANGR_NATIVE}: ${OBJS} sim_unicorn.cpp
	${C++C} ${CFLAGS} -shared -o $@ $^ ${LIBS}

clean:
	rm -f ${LIB_ANGR_NATIVE} *.o arch/*.o
